#ifndef OBJECT_H
#define OBJECT_H

#include <iostream>
#include <fstream>

using namespace std;

class Field;

enum Team{ TEAMENUM = 0, TEAMID, TEAMDEMON };
enum TEAMCHAR{ TEAMENUMCHAR = 'G', TEAMIDCHAR = 'R', TEAMDEMONCHAR = 'D' };
enum Direction{ NORTH = 0, NORTHEAST, EAST, SOUTHEAST,
                 SOUTH, SOUTHWEST, WEST, NORTHWEST, NONE };

  // returns random team
Team randomTeam();

  // parent class for all objects
class Object
{
    public:
        Object( int x_ = -1, int y_ = -1, Field* f_ = 0, bool status = true )
            :x(x_), y(y_), f(f_), updateStatus(status)
        {}

          // is called every time object updates
        virtual void update( int updateNumber ) = 0;

          // paints the object
        void paint();

          // moves mob to another position with coordinates x and y
        void move( int x, int y );
          // damages an object by value amount of damage
        virtual void damage( int ) {}
          // saves the object in file, used for saving field
        virtual void save( ofstream* save, ofstream* ){ (*save) << getSymbol(); }

        int getX() const { return x; }
        int getY() const { return y; }
        bool getUpdateStatus() const { return updateStatus; }
        Field* getField() const { return f; }

        void setX( int x_ ) { x = x_; }
        void setY( int y_ ) { y = y_; }
        void setUpdateStatus( bool a ) { updateStatus = a; }
        void setField( Field* _f ) { f = _f; }

        virtual ~Object() {}

          // returns symbol, which will represent the object
        virtual char getSymbol() const = 0;
          // used by all mob classes to indetify teams
        virtual Team getTeam() const { return Team ( 0 ); }
          // used by field to do some bullet-related checks
        virtual Direction getDirection() const { return Direction ( 0 ); }

        virtual bool isPlayer() const { return false; }
    protected:
    private:
        int x, y;

          // pointer to field to which this object belongs
        Field* f;

          // 1 if object requires repainting, 0 if it doesn't
          // not used anymore, switching to "paint all at once"
          // style
        bool updateStatus;
};

#endif // OBJECT_H
